package crm.servlet;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import crm.service.EmployeeService;
import crm.service.impl.EmployeeServiceImpl;

/**
 * Servlet implementation class UpdateEmployeePassword
 */
public class UpdateEmployeePassword extends HttpServlet {
	private static final long serialVersionUID = 1L;

    private EmployeeService employeeService = new EmployeeServiceImpl();
	
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		String EmployeeID = request.getParameter("employeeID");
		String password = request.getParameter("password");
		
		System.out.println(EmployeeID);
		System.out.println(password);
		
		try {
			
			
			employeeService.updateEmployeePassword(Integer.parseInt(password), Integer.parseInt(EmployeeID));
			
			
		} catch (SQLException | RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		response.sendRedirect("login.jsp");
		
	}

}
